﻿Public Class ClaseDevolución
#Region " Campos "
    Private campoId As Integer
    Private campoFecha As Date
    Private campoDescripcion As String
    Private campoEstado As String
    Private campoIDPrestamo As Integer
#End Region



#Region " Propiedades "
    Public Property ID() As Integer
        Get
            Return campoId
        End Get
        Set(ByVal value As Integer)
            campoId = value
        End Set
    End Property

    Public Property Fecha() As Date
        Get
            Return campoFecha
        End Get
        Set(ByVal value As Date)
            campoFecha = value
        End Set
    End Property

    Public Property Estado() As String
        Get
            Return campoEstado
        End Get
        Set(ByVal value As String)
            campoEstado = value
        End Set
    End Property

    Public Property Descripcion() As String
        Get
            Return campoDescripcion
        End Get
        Set(ByVal value As String)
            campoDescripcion = value
        End Set
    End Property
#End Region

    Public Sub New()
        MyClass.campoEstado = "Pendiente"
        MyClass.campoDescripcion = "Sin devolver"
        MyClass.campoFecha = CDate(System.Data.SqlTypes.SqlDateTime.Null)
    End Sub

    Public Sub Grabar()
        Dim grabador As New ClaseGestorDevolucion
        grabador.Devolucion = Me
        MyClass.ID = grabador.Grabar()
    End Sub

    Public Sub Prorrogar()
        With Me
            .Estado = "Prorrogada"
            .Descripcion = "Prorrogada"
            .Fecha = Date.Now        
        End With
        MyClass.Grabar()
    End Sub

    Public Sub NextId()
        MyClass.ID = ClaseGestorDevolucion.NextId
    End Sub

    Public Sub Devolver()
        With Me
            .Estado = "Concretada"
            .Descripcion = "Concretada"
            .Fecha = Date.Now
        End With
        MyClass.Grabar()
    End Sub

    Public Sub Anular()
        With Me
            .Estado = "Anulado"
            .Descripcion = "Cancelada"
            .Fecha = Date.Now
        End With
        MyClass.Grabar()
    End Sub
    Public Sub DevolverEnMora()
        MyClass.Estado = "Concretada"
        MyClass.Descripcion = "En mora"
        MyClass.Fecha = Date.Now
        MyClass.Grabar()
    End Sub

    Public Sub DevolverUna(ByVal id As Integer)
        Dim gestor As New ClaseGestorDevolucion
        Me.ID = id
        gestor.Devolucion = Me

    End Sub

End Class
